
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>佰林の密码修改</title>
    <link rel="stylesheet" href="/common/layui/css/layui.css">
    <link rel="stylesheet" href="/admin/css/style.css">
    <script src="/common/layui/layui.js"></script>
    <script src="/common/jquery-3.3.1.min.js"></script>
    <script src="/common/vue.min.js"></script>
</head>
<body>
    <div class="main" id="app">
        <div id="fixedData">
            <!--顶栏-->
            <header>
                <h1 v-text="webname"></h1>
                <div class="breadcrumb">
                    <i class="layui-icon">&#xe715;</i>
                    <ul>
                        <li v-for="vo in address">
                            <a  v-text="vo.name" :href="vo.url" ></a> <span>/</span>
                        </li>
                    </ul>
                </div>
                <a>管理员列表</a>
            </header>
            <!--左栏-->
            <div class="left">
                <ul class="cl" >
                    <!--顶级分类-->
                    <li v-for="vo,index in menu" :class="{hidden:vo.hidden}">
                        <a href="javascript:;"  :class="{active:vo.active}"  @click="onActive(index)">
                            <i class="layui-icon" v-html="vo.icon"></i>
                            <span v-text="vo.name"></span>
                            <i class="layui-icon arrow" v-show="vo.url.length==0">&#xe61a;</i> <i v-show="vo.active" class="layui-icon active">&#xe623;</i>
                        </a>
                        <!--子级分类-->
                        <div v-for="vo2,index2 in vo.list">
                            <a href="javascript:;" :class="{active:vo2.active}" @click="onActive(index,index2)" v-text="vo2.name"></a>
                            <i v-show="vo2.active" class="layui-icon active">&#xe623;</i>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
        <!--右侧-->
        <div class="right" id="Right">
            <div class="layui-form" action="" >
                <div class="layui-form-item">
                    <label class="layui-form-label">密码框</label>
                    <div class="layui-input-inline">
                        <input type="password" name="password" v-model="password" required lay-verify="required" placeholder="请输入密码"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">确认密码框</label>
                    <div class="layui-input-block">
                        <input type="password" name="title" v-model="confirmPassword"  required lay-verify="required" placeholder="请输入标题"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn"  @click="setSubmit">修改</button>
                    </div>
                </div>
            </div>


        </div>
    </div>
<script src="/admin/js/config.js"></script>
<script>
    let right = new Vue({
        el:'#Right',
        data: {
            confirmPassword:'',
            password:'',
            adminId:''
        },
        methods:{
            setSubmit(){
             let oldPwd = JSON.parse(localStorage.getItem('adminInfo')).password;
             if(oldPwd === this.password){
                 layui.use('layer', function(){
                     var layer = layui.layer;
                     layer.msg('修改密码不可与原密码一致');
                 });
                 return
             }
              if(this.password===this.confirmPassword){
                  $.ajax({
                      url:'showAdminrList/update',
                      type:'post',
                      data:JSON.stringify(
                          {
                              id:this.adminId,
                              password:this.password
                          }
                      ),
                      contentType: "application/json;charset=UTF-8",
                      success: (data)=> {
                          layui.use('layer', function(){
                              var layer = layui.layer;
                              layer.msg('修改成功');
                              setTimeout(()=>{
                                  window.location.href='/toAdminLogin';
                              },2000)
                          });
                      }
                  })
              }else{
                  layui.use('layer', function(){
                      var layer = layui.layer;
                      layer.msg('两次密码不一致请重新输入');
                  });
              }
            }
        },
        mounted(){
            this.adminId = JSON.parse(localStorage.getItem('adminInfo')).id
            console.log(this.adminId,1233322)
        }
    })
</script>
</body>
</html>
